/**
 * Created by Chris on 14-9-5.
 * The bootstrap js for butterfly .
 * use below code in your module(s) to init the framework.
 * <script type="text/javascript" src="../butterfly/js/require.js" data-main="../butterfly/js/butterfly-bootstrap"></script>
 * Dependencies: require.js
 */
require.config({
    baseUrl: '../',
    packages: [{
        name: 'butterfly',
        location: 'butterfly/js',
        main: 'butterfly'
    },
        {
        name: 'butterflysoc',
        location: 'butterfly/js/soc'
    }
    ], 
    paths: {
        // require.js plugins
        text        : 'butterfly/vendor/requirejs-text/text',
        domReady    : 'butterfly/vendor/requirejs-domready/domready',
        i18n        : 'butterfly/vendor/requirejs-i18n/i18n',
        css         : 'butterfly/vendor/require-css/css',
        link        : 'butterfly/vendor/require-link/link',
        view        : 'butterfly/js/requirejs-butterfly',
        // lib
        jquery      : 'butterfly/vendor/zepto/js/zepto',
        zepto       : 'butterfly/js/soc/zepto_proxy',

//        jquery      : 'butterfly/vendor/jquery/jquery',
//        zepto       : 'piece/js/vendor/zepto/js/zepto',

        underscore  : 'butterfly/vendor/underscore/underscore',
        backbone    : 'butterfly/vendor/backbone/backbone',
        fastclick   : 'butterfly/vendor/fastclick/fastclick',
        iscroll     : 'butterfly/vendor/iscroll/iscroll-probe',
        moment      : 'butterfly/vendor/moment/moment',
        spin        : 'butterfly/vendor/spinjs/spin',

//        piece
        swipe       : 'butterfly/js/soc/vendor/swipe',

        gmu         : 'butterfly/js/soc/components/gmu',
        // should be ok, but cannot switch language
        gmunls      : 'butterfly/js/soc/components/nls/gmu',

        //path
//        vendor      : 'piece/js/vendor',
//        core        : 'piece/js/core',
//        components  : 'piece/js/components',

        // soc only
//        urlConfig    : "com_csair_base/urlConfig",
        cubei18n    : "butterfly/js/soc/components/cubei18n",
        session     : "butterfly/js/soc/components/session",

        photoswipe  :"butterfly/vendor/photoswipe/photoswipe",
        photoswipe_ui_default  :"butterfly/vendor/photoswipe/photoswipe-ui-default",

        async : "butterfly/js/async"



    },
    waitSeconds: 5,
    shim: {

		jquery: {   exports: '$'},
//        zepto: {    deps: ['jquery'] },
//        urlConfig: {exports: 'UrlConfig', deps:['jquery']},
//        zepto: {exports: '$'},

        gmu: {
            exports: 'gmu',
            deps: ['jquery'
                ,'i18n',
                'gmunls'
//                'i18n!butterfly/soc/components/nls/gmu'
            ]
        },
        gmunls: {

        },
        swipe: {
            exports: 'Swipe'
        },
        photoswipe: {
            exports: 'PhotoSwipe'
        },
        photoswipe_ui_default: {
            exports: 'PhotoSwipeUI_Default'
        },
        underscore: {exports: '_'},
        backbone: {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        },
        iscroll: {exports: 'IScroll'},
        fastclick: {exports: 'FastClick'},
        async:{exports: 'async'}

    },
    config:{
        i18n: {
            locale: 'zh-cn'//window.localStorage['lang']
        }
    }
});


require(['butterfly', 'iscroll', 'butterfly/fastclick'],
    function(Butterfly, IScroll, FastClick){

        window.localStorage['lang'] = 'zh-cn';

        //ios7 issue fix
        if (navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i)) {
            $('html').addClass('ipad ios7');
        }
        //iOS scroll to top
        setTimeout(function() {window.scrollTo(0, 1);}, 0);


        //enable fastclick
        FastClick.attach(document.body);

        //this will stop the page from scrolling without IScroll
        // document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);


    });



